<!DOCTYPE html>
<meta charset="UTF-8">
<div style="padding: 10px;">
	<ul id="tree_actions_id" data-type="tree"
		data-defs="method:'get',url: 'demo/testdata/tree_data1.json',animate:true,lines:true"></ul>
	<div style="margin: 10px 0;">
		<a href="#" data-type="button" data-defs="'width':120" onclick="collapseAll()">关闭</a>
		<a href="#" data-type="button" data-defs="'width':120" onclick="expandAll()">展开</a>
		<a href="#" data-type="button" data-defs="'width':120" onclick="expandTo()">选择节点</a>
		<a href="#" data-type="button" data-defs="'width':120" onclick="getSelected()">获得选择的节点</a>
	</div>
</div>
<script type="text/javascript">
	function collapseAll() {
	    $('#tree_actions_id').tree('collapseAll');
    }
    function expandAll() {
	    $('#tree_actions_id').tree('expandAll');
    }
    function expandTo() {
	    var node = $('#tree_actions_id').tree('find', 113);
	    $('#tree_actions_id').tree('expandTo', node.target).tree('select', node.target);
    }
    function getSelected() {
	    var node = $('#tree_actions_id').tree('getSelected');
	    if (node) {
		    var s = node.text;
		    if (node.attributes) {
			    s += "," + node.attributes.p1 + "," + node.attributes.p2;
		    }
		    alert(s);
	    }
    }
</script>
